// 全局变量
const globalObj = {};

// 定义公共变量
globalObj.name = '小明';

// 定义公共方法
globalObj.getAge = function (birthYear) {
  return new Date().getFullYear() - birthYear;
};
// 定义公共方法
globalObj.getAge = function (birthYear) {
  return new Date().getFullYear() - birthYear;
};
// /utils/index.js
globalObj.dateFormat = function(date) {
  var y = date.getFullYear();
  var m = date.getMonth() + 1;
  m = m < 10 ? ('0' + m) : m;
  var d = date.getDate();
  d = d < 10 ? ('0' + d) : d;
  var h = date.getHours();
  var minute = date.getMinutes();
  minute = minute < 10 ? ('0' + minute) : minute;
  var second= date.getSeconds();
  second = minute < 10 ? ('0' + second) : second;
  return y +  m + d + h + minute + second;
}

globalObj.dateFormatYMD = function(date) {
  var y = date.getFullYear();
  var m = date.getMonth() + 1;
  m = m < 10 ? ('0' + m) : m;
  var d = date.getDate();
  d = d < 10 ? ('0' + d) : d;
  return y +  m + d;
}

globalObj.dateFormatYMDH = function(date) {
  var y = date.getFullYear();
  var m = date.getMonth() + 1;
  m = m < 10 ? ('0' + m) : m;
  var d = date.getDate();
  d = d < 10 ? ('0' + d) : d;
  var h = date.getHours();
  return y +  m + d + h;
}

export default globalObj
